/***

    PlotKit.PlotKit 0.9.2 : PACKED VERSION

    THIS FILE IS AUTOMATICALLY GENERATED.  If creating patches, please
    diff against the source tree, not this file.

    For more information, <http://www.liquidx.net/plotkit/>.
    
    Copyright (c) 2006. Alastair Tse.

***/

try{
if(typeof (MochiKit.Base)=="undefined"||typeof (MochiKit.DOM)=="undefined"||typeof (MochiKit.Color)=="undefined"||typeof (MochiKit.Format)=="undefined"){
throw "";
}
}
catch(e){
throw "PlotKit depends on MochiKit.{Base,Color,DOM,Format}";
}
MochiKit.Base.update(MochiKit.Color.Color.prototype,{asFillColor:function(){
return this.lighterColorWithLevel(0.3);
},asStrokeColor:function(){
return this.darkerColorWithLevel(0.1);
},asPointColor:function(){
return this.lighterColorWithLevel(0.1);
},asTransparent:function(){
return this.colorWithAlpha(0.1);
}});
if(typeof (PlotKit)=="undefined"){
PlotKit={};
}
PlotKit.NAME="PlotKit";
PlotKit.VERSION="0.9.2";
PlotKit.__repr__=function(){
return "["+this.NAME+" "+this.VERSION+"]";
};
PlotKit.toString=function(){
return this.__repr__();
};
if(typeof (PlotKit.Base)=="undefined"){
PlotKit.Base={};
}
PlotKit.Base.NAME="PlotKit.Base";
PlotKit.Base.VERSION=PlotKit.VERSION;
PlotKit.Base.__repr__=function(){
return "["+this.NAME+" "+this.VERSION+"]";
};
PlotKit.Base.toString=function(){
return this.__repr__();
};
PlotKit.Base.usingPrototype=function(){
try{
return (typeof (Object.extend)=="function");
}
catch(e){
return false;
}
};
MochiKit.Base.update(PlotKit.Base,{roundInterval:function(_1,_2,_3){
var _4=MochiKit.Format.roundToFixed;
var _5=_1/_2;
return parseFloat(_4(_5,_3));
},collapse:function(_6){
var m=MochiKit.Base;
var _8=new Array();
for(var i=0;i<_6.length;i++){
_8=m.concat(_8,_6[i]);
}
if(PlotKit.Base.usingPrototype()){
delete _8.extend;
delete _8.from;
delete _8.inspect;
}
return _8;
},uniq:function(_10){
var m=MochiKit.Base;
if(!m.isArrayLike(_10)||(_10.length<1)){
return new Array();
}
var _11=new Array();
var _12=_10[0];
_11.push(_10[0]);
for(var i=1;i<_10.length;i++){
if(m.compare(_10[i],_12)!=0){
_12=_10[i];
_11.push(_10[i]);
}
}
return _11;
},colorScheme:function(){
var mb=MochiKit.Base;
var mc=MochiKit.Color;
var _15=["red","orange","yellow","green","cyan","blue","purple","magenta"];
var _16=function(_17){
return mc.Color[_17+"Color"]();
};
return mb.map(_16,_15);
},baseDarkPrimaryColors:function(){
var _18=MochiKit.Color.Color.fromHexString;
return [_18("#ad3f40"),_18("#ddac2c"),_18("#dfdd0c"),_18("#5276c4"),_18("#739c5a")];
},basePrimaryColors:function(){
var _19=MochiKit.Color.Color.fromHexString;
return [_19("#d24c4d"),_19("#f2b32f"),_19("#ece90e"),_19("#5d83da"),_19("#78a15d")];
},baseBlueColors:function(){
var _20=MochiKit.Color.Color.fromHexString;
return [_20("#4b6b94"),_20("#5d81b4"),_20("#acbad2")];
},palette:function(_21,_22,_23,_24){
var _25=MochiKit.Base.isUndefinedOrNull;
var _26=new Array();
if(_25(_24)){
_24=0.1;
}
if(_25(_23)){
_23=0.4;
}
if(_25(_22)){
_22=-0.2;
}
var _27=_22;
while(_27<=_23){
_26.push(_27);
_27+=_24;
}
var _28=function(_29,_30){
return _29.lighterColorWithLevel(_30);
};
return MochiKit.Base.map(MochiKit.Base.partial(_28,_21),_26);
},excanvasSupported:function(){
if(/MSIE/.test(navigator.userAgent)&&!window.opera){
return true;
}
return false;
},findPosX:function(obj){
var _32=0;
if(obj.offsetParent){
while(obj.offsetParent){
_32+=obj.offsetLeft;
obj=obj.offsetParent;
}
}else{
if(obj.x){
_32+=obj.x;
}
}
return _32;
},findPosY:function(obj){
var _33=0;
if(obj.offsetParent){
while(obj.offsetParent){
_33+=obj.offsetTop;
obj=obj.offsetParent;
}
}else{
if(obj.y){
_33+=obj.y;
}
}
return _33;
},isFuncLike:function(obj){
return (typeof (obj)=="function");
}});
PlotKit.Base.map=function(fn,lst){
if(PlotKit.Base.usingPrototype()){
var _36=[];
for(var x in lst){
if(typeof (lst[x])=="function"){
continue;
}
_36.push(fn(lst[x]));
}
return _36;
}else{
return MochiKit.Base.map(fn,lst);
}
};
PlotKit.Base.items=function(lst){
if(PlotKit.Base.usingPrototype()){
var _38=[];
for(var x in lst){
if(typeof (lst[x])=="function"){
continue;
}
_38.push([x,lst[x]]);
}
return _38;
}else{
return MochiKit.Base.items(lst);
}
};
PlotKit.Base.keys=function(lst){
if(PlotKit.Base.usingPrototype()){
var _39=[];
for(var x in lst){
if(typeof (lst[x])=="function"){
continue;
}
_39.push(x);
}
return _39;
}else{
return MochiKit.Base.keys(lst);
}
};
PlotKit.Base.baseColors=function(){
var _40=MochiKit.Color.Color.fromHexString;
return [_40("#476fb2"),_40("#be2c2b"),_40("#85b730"),_40("#734a99"),_40("#26a1c5"),_40("#fb8707"),_40("#000000")];
};
PlotKit.Base.googleColors=function(){
var _41=MochiKit.Color.Color.fromHexString;
return [_41("#0066dd"),_41("#dc3912"),_41("#ff9900"),_41("#008000"),_41("#4942cc"),_41("#990099")];
};
PlotKit.Base.googleStyle=function(){
var r={"colorScheme":PlotKit.Base.googleColors(),"backgroundColor":MochiKit.Color.Color.whiteColor(),"strokeWidth":2,"axisLineWidth":2,"strokeColor":null,"strokeColorTransform":null,"fillColorTransform":"asTransparent","shouldFill":true};
return r;
};
PlotKit.Base.officeBaseStyle={"axisLineWidth":2,"axisLabelColor":MochiKit.Color.Color.grayColor(),"axisLineColor":MochiKit.Color.Color.whiteColor(),"padding":{top:5,bottom:10,left:30,right:30}};
MochiKit.Base.update(PlotKit.Base,{officeBlue:function(){
var r={"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[0]),"backgroundColor":PlotKit.Base.baseColors()[0].lighterColorWithLevel(0.45)};
MochiKit.Base.update(r,PlotKit.Base.officeBaseStyle);
return r;
},officeRed:function(){
var r={"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[1]),"backgroundColor":PlotKit.Base.baseColors()[1].lighterColorWithLevel(0.5)};
MochiKit.Base.update(r,PlotKit.Base.officeBaseStyle);
return r;
},officeGreen:function(){
var r={"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[2]),"backgroundColor":PlotKit.Base.baseColors()[2].lighterColorWithLevel(0.5)};
MochiKit.Base.update(r,PlotKit.Base.officeBaseStyle);
return r;
},officePurple:function(){
var r={"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[3]),"backgroundColor":PlotKit.Base.baseColors()[3].lighterColorWithLevel(0.5)};
MochiKit.Base.update(r,PlotKit.Base.officeBaseStyle);
return r;
},officeCyan:function(){
var r={"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[4]),"backgroundColor":PlotKit.Base.baseColors()[4].lighterColorWithLevel(0.5)};
MochiKit.Base.update(r,PlotKit.Base.officeBaseStyle);
return r;
},officeOrange:function(){
var r={"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[5]),"backgroundColor":PlotKit.Base.baseColors()[5].lighterColorWithLevel(0.4)};
MochiKit.Base.update(r,PlotKit.Base.officeBaseStyle);
return r;
},officeBlack:function(){
var r={"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[6],0,0.6),"backgroundColor":PlotKit.Base.baseColors()[6].lighterColorWithLevel(0.9)};
MochiKit.Base.update(r,PlotKit.Base.officeBaseStyle);
return r;
}});
PlotKit.Base.EXPORT=["baseColors","collapse","colorScheme","findPosX","findPosY","officeBaseStyle","officeBlue","officeRed","officeGreen","officePurple","officeCyan","officeOrange","officeBlack","roundInterval","uniq","isFuncLike","excanvasSupported"];
PlotKit.Base.EXPORT_OK=[];
PlotKit.Base.__new__=function(){
var m=MochiKit.Base;
m.nameFunctions(this);
this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
};
PlotKit.Base.__new__();
MochiKit.Base._exportSymbols(this,PlotKit.Base);
try{
if(typeof (PlotKit.Base)=="undefined"){
throw "";
}
}
catch(e){
throw "PlotKit.Layout depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.Base";
}
if(typeof (PlotKit.Layout)=="undefined"){
PlotKit.Layout={};
}
PlotKit.Layout.NAME="PlotKit.Layout";
PlotKit.Layout.VERSION=PlotKit.VERSION;
PlotKit.Layout.__repr__=function(){
return "["+this.NAME+" "+this.VERSION+"]";
};
PlotKit.Layout.toString=function(){
return this.__repr__();
};
PlotKit.Layout.valid_styles=["bar","line","pie","point"];
PlotKit.Layout=function(_43,_44){
this.options={"barWidthFillFraction":0.75,"barOrientation":"vertical","xOriginIsZero":true,"yOriginIsZero":true,"xAxis":null,"yAxis":null,"xTicks":null,"yTicks":null,"xNumberOfTicks":10,"yNumberOfTicks":5,"xTickPrecision":1,"yTickPrecision":1,"pieRadius":0.4};
this.style=_43;
MochiKit.Base.update(this.options,_44?_44:{});
if(!MochiKit.Base.isUndefinedOrNull(this.options.xAxis)){
this.minxval=this.options.xAxis[0];
this.maxxval=this.options.xAxis[1];
this.xscale=this.maxxval-this.minxval;
}else{
this.minxval=0;
this.maxxval=null;
this.xscale=null;
}
if(!MochiKit.Base.isUndefinedOrNull(this.options.yAxis)){
this.minyval=this.options.yAxis[0];
this.maxyval=this.options.yAxis[1];
this.yscale=this.maxyval-this.minyval;
}else{
this.minyval=0;
this.maxyval=null;
this.yscale=null;
}
this.bars=new Array();
this.points=new Array();
this.slices=new Array();
this.xticks=new Array();
this.yticks=new Array();
this.datasets=new Array();
this.minxdelta=0;
this.xrange=1;
this.yrange=1;
this.hitTestCache={x2maxy:null};
};
PlotKit.Layout.prototype.addDataset=function(_45,_46){
this.datasets[_45]=_46;
};
PlotKit.Layout.prototype.removeDataset=function(_47,_48){
delete this.datasets[_47];
};
PlotKit.Layout.prototype.addDatasetFromTable=function(_49,_50,_51,_52,_53){
var _54=MochiKit.Base.isUndefinedOrNull;
var _55=MochiKit.DOM.scrapeText;
var _56=MochiKit.Format.strip;
if(_54(_51)){
_51=0;
}
if(_54(_52)){
_52=1;
}
if(_54(_53)){
_53=-1;
}
var _57=_50.tBodies[0].rows;
var _58=new Array();
var _59=new Array();
if(!_54(_57)){
for(var i=0;i<_57.length;i++){
_58.push([parseFloat(_56(_55(_57[i].cells[_51]))),parseFloat(_56(_55(_57[i].cells[_52])))]);
if(_53>=0){
_59.push({v:parseFloat(_56(_55(_57[i].cells[_51]))),label:_56(_55(_57[i].cells[_53]))});
}
}
this.addDataset(_49,_58);
if(_53>=0){
this.options.xTicks=_59;
}
return true;
}
return false;
};
PlotKit.Layout.prototype.evaluate=function(){
this._evaluateLimits();
this._evaluateScales();
if(this.style=="bar"){
if(this.options.barOrientation=="horizontal"){
this._evaluateHorizBarCharts();
}else{
this._evaluateBarCharts();
}
this._evaluateBarTicks();
}else{
if(this.style=="line"){
this._evaluateLineCharts();
this._evaluateLineTicks();
}else{
if(this.style=="pie"){
this._evaluatePieCharts();
this._evaluatePieTicks();
}
}
}
};
PlotKit.Layout.prototype.hitTest=function(x,y){
var f=MochiKit.Format.twoDigitFloat;
if((this.style=="bar")&&this.bars&&(this.bars.length>0)){
for(var i=0;i<this.bars.length;i++){
var bar=this.bars[i];
if((x>=bar.x)&&(x<=bar.x+bar.w)&&(y>=bar.y)&&(y-bar.y<=bar.h)){
return bar;
}
}
}else{
if(this.style=="line"){
if(this.hitTestCache.x2maxy==null){
this._regenerateHitTestCache();
}
var _63=x/this.xscale;
var _64=this.hitTestCache.xvalues;
var _65=null;
var _66=null;
for(var i=1;i<_64.length;i++){
if(_64[i]>_63){
_65=_64[i-1];
_66=_64[i];
break;
}
}
if((_65!=null)){
var _67=this.hitTestCache.x2maxy[_65];
var _68=this.hitTestCache.x2maxy[_66];
var _69=(1-y)/this.yscale;
var _70=(_68-_67)/(_66-_65);
var _71=_67+_70*(_63-_65);
if(_71>=_69){
var obj={xval:_63,yval:_69,xafter:_66,yafter:_68,xbefore:_65,ybefore:_67,yprojected:_71};
return obj;
}
}
}else{
if(this.style=="pie"){
x=2*x-0.5;
var _72=Math.sqrt((y-0.5)*(y-0.5)+(x-0.5)*(x-0.5));
if(_72>this.options.pieRadius){
return null;
}
var _73=0;
if(y<0.5&&x<0.5){
_73=Math.atan2(y-0.5,x-0.5)+5*Math.PI/2;
}else{
_73=Math.atan2(y-0.5,x-0.5)+Math.PI/2;
}
for(var i=0;i<this.slices.length;i++){
var _74=this.slices[i];
if(_74.startAngle<_73&&_74.endAngle>=_73){
return _74;
}
}
}
}
}
return null;
};
PlotKit.Layout.prototype.rectForX=function(x){
return null;
};
PlotKit.Layout.prototype.angleRangeForX=function(x){
return null;
};
PlotKit.Layout.prototype._evaluateLimits=function(){
var map=PlotKit.Base.map;
var _76=PlotKit.Base.items;
var _77=MochiKit.Base.itemgetter;
var _78=PlotKit.Base.collapse;
var _79=MochiKit.Base.listMin;
var _80=MochiKit.Base.listMax;
var _81=MochiKit.Base.isUndefinedOrNull;
var all=_78(map(_77(1),_76(this.datasets)));
if(_81(this.options.xAxis)){
if(this.options.xOriginIsZero){
this.minxval=0;
}else{
this.minxval=_79(map(parseFloat,map(_77(0),all)));
}
this.maxxval=_80(map(parseFloat,map(_77(0),all)));
}else{
this.minxval=this.options.xAxis[0];
this.maxxval=this.options.xAxis[1];
this.xscale=this.maxval-this.minxval;
}
if(_81(this.options.yAxis)){
if(this.options.yOriginIsZero){
this.minyval=0;
}else{
this.minyval=_79(map(parseFloat,map(_77(1),all)));
}
this.maxyval=_80(map(parseFloat,map(_77(1),all)));
}else{
this.minyval=this.options.yAxis[0];
this.maxyval=this.options.yAxis[1];
this.yscale=this.maxyval-this.minyval;
}
};
PlotKit.Layout.prototype._evaluateScales=function(){
var _83=MochiKit.Base.isUndefinedOrNull;
this.xrange=this.maxxval-this.minxval;
if(this.xrange==0){
this.xscale=1;
}else{
this.xscale=1/this.xrange;
}
this.yrange=this.maxyval-this.minyval;
if(this.yrange==0){
this.yscale=1;
}else{
this.yscale=1/this.yrange;
}
};
PlotKit.Layout.prototype._uniqueXValues=function(){
var _84=PlotKit.Base.collapse;
var map=PlotKit.Base.map;
var _85=PlotKit.Base.uniq;
var _86=MochiKit.Base.itemgetter;
var _87=PlotKit.Base.items;
var _88=map(parseFloat,map(_86(0),_84(map(_86(1),_87(this.datasets)))));
_88.sort(MochiKit.Base.compare);
return _85(_88);
};
PlotKit.Layout.prototype._evaluateBarCharts=function(){
var _89=PlotKit.Base.items;
var _90=_89(this.datasets).length;
var _91=10000000;
var _92=this._uniqueXValues();
for(var i=1;i<_92.length;i++){
_91=Math.min(Math.abs(_92[i]-_92[i-1]),_91);
}
var _93=0;
var _94=0;
var _95=0;
if(_92.length==1){
_91=1;
this.xscale=1;
this.minxval=_92[0];
_93=1*this.options.barWidthFillFraction;
_94=_93/_90;
_95=(1-this.options.barWidthFillFraction)/2;
}else{
if(this.xrange==1){
this.xscale=0.5;
}else{
if(this.xrange==2){
this.xscale=1/3;
}else{
this.xscale=(1-_91/this.xrange)/this.xrange;
}
}
_93=_91*this.xscale*this.options.barWidthFillFraction;
_94=_93/_90;
_95=_91*this.xscale*(1-this.options.barWidthFillFraction)/2;
}
this.minxdelta=_91;
this.bars=new Array();
var i=0;
for(var _96 in this.datasets){
var _97=this.datasets[_96];
if(PlotKit.Base.isFuncLike(_97)){
continue;
}
for(var j=0;j<_97.length;j++){
var _99=_97[j];
var rect={x:((parseFloat(_99[0])-this.minxval)*this.xscale)+(i*_94)+_95,y:1-((parseFloat(_99[1])-this.minyval)*this.yscale),w:_94,h:((parseFloat(_99[1])-this.minyval)*this.yscale),xval:parseFloat(_99[0]),yval:parseFloat(_99[1]),name:_96};
if((rect.x>=0)&&(rect.x<=1)&&(rect.y>=0)&&(rect.y<=1)){
this.bars.push(rect);
}
}
i++;
}
};
PlotKit.Layout.prototype._evaluateHorizBarCharts=function(){
var _101=PlotKit.Base.items;
var _102=_101(this.datasets).length;
var _103=10000000;
var _104=this._uniqueXValues();
for(var i=1;i<_104.length;i++){
_103=Math.min(Math.abs(_104[i]-_104[i-1]),_103);
}
var _105=0;
var _106=0;
var _107=0;
if(_104.length==1){
_103=1;
this.xscale=1;
this.minxval=_104[0];
_105=1*this.options.barWidthFillFraction;
_106=_105/_102;
_107=(1-this.options.barWidthFillFraction)/2;
}else{
this.xscale=(1-_103/this.xrange)/this.xrange;
_105=_103*this.xscale*this.options.barWidthFillFraction;
_106=_105/_102;
_107=_103*this.xscale*(1-this.options.barWidthFillFraction)/2;
}
this.minxdelta=_103;
this.bars=new Array();
var i=0;
for(var _108 in this.datasets){
var _109=this.datasets[_108];
if(PlotKit.Base.isFuncLike(_109)){
continue;
}
for(var j=0;j<_109.length;j++){
var item=_109[j];
var rect={y:((parseFloat(item[0])-this.minxval)*this.xscale)+(i*_106)+_107,x:0,h:_106,w:((parseFloat(item[1])-this.minyval)*this.yscale),xval:parseFloat(item[0]),yval:parseFloat(item[1]),name:_108};
if(rect.y<=0){
rect.y=0;
}
if(rect.y>=1){
rect.y=1;
}
if((rect.x>=0)&&(rect.x<=1)){
this.bars.push(rect);
}
}
i++;
}
};
PlotKit.Layout.prototype._evaluateLineCharts=function(){
var _111=PlotKit.Base.items;
var _112=_111(this.datasets).length;
this.points=new Array();
var i=0;
for(var _113 in this.datasets){
var _114=this.datasets[_113];
if(PlotKit.Base.isFuncLike(_114)){
continue;
}
_114.sort(function(a,b){
return MochiKit.Base.compare(parseFloat(a[0]),parseFloat(b[0]));
});
for(var j=0;j<_114.length;j++){
var item=_114[j];
var _117={x:((parseFloat(item[0])-this.minxval)*this.xscale),y:1-((parseFloat(item[1])-this.minyval)*this.yscale),xval:parseFloat(item[0]),yval:parseFloat(item[1]),name:_113};
if(_117.y<=0){
_117.y=0;
}
if(_117.y>=1){
_117.y=1;
}
if((_117.x>=0)&&(_117.x<=1)){
this.points.push(_117);
}
}
i++;
}
};
PlotKit.Layout.prototype._evaluatePieCharts=function(){
var map=PlotKit.Base.map;
var _118=PlotKit.Base.items;
var sum=MochiKit.Iter.sum;
var _120=MochiKit.Base.itemgetter;
var _121=_118(this.datasets).length;
var _122=_118(this.datasets)[0][1];
var _123=sum(map(_120(1),_122));
this.slices=new Array();
var _124=0;
for(var i=0;i<_122.length;i++){
var _125=_122[i][1]/_123;
var _126=_124*Math.PI*2;
var _127=(_124+_125)*Math.PI*2;
var _128={fraction:_125,xval:_122[i][0],yval:_122[i][1],startAngle:_126,endAngle:_127};
if(_122[i][1]!=0){
this.slices.push(_128);
}
_124+=_125;
}
};
PlotKit.Layout.prototype._evaluateLineTicksForXAxis=function(){
var _129=MochiKit.Base.isUndefinedOrNull;
if(this.options.xTicks){
this.xticks=new Array();
var _130=function(tick){
var _132=tick.label;
if(_129(_132)){
_132=tick.v.toString();
}
var pos=this.xscale*(tick.v-this.minxval);
if((pos>=0)&&(pos<=1)){
this.xticks.push([pos,_132]);
}
};
MochiKit.Iter.forEach(this.options.xTicks,MochiKit.Base.bind(_130,this));
}else{
if(this.options.xNumberOfTicks){
var _134=this._uniqueXValues();
var _135=this.xrange/this.options.xNumberOfTicks;
var _136=0;
this.xticks=new Array();
for(var i=0;i<=_134.length;i++){
if((_134[i]-this.minxval)>=(_136*_135)){
var pos=this.xscale*(_134[i]-this.minxval);
if((pos>1)||(pos<0)){
continue;
}
this.xticks.push([pos,_134[i]]);
_136++;
}
if(_136>this.options.xNumberOfTicks){
break;
}
}
}
}
};
PlotKit.Layout.prototype._evaluateLineTicksForYAxis=function(){
var _137=MochiKit.Base.isUndefinedOrNull;
if(this.options.yTicks){
this.yticks=new Array();
var _138=function(tick){
var _139=tick.label;
if(_137(_139)){
_139=tick.v.toString();
}
var pos=1-(this.yscale*(tick.v-this.minyval));
if((pos>=0)&&(pos<=1)){
this.yticks.push([pos,_139]);
}
};
MochiKit.Iter.forEach(this.options.yTicks,MochiKit.Base.bind(_138,this));
}else{
if(this.options.yNumberOfTicks){
this.yticks=new Array();
var _140=PlotKit.Base.roundInterval;
var prec=this.options.yTickPrecision;
var _142=_140(this.yrange,this.options.yNumberOfTicks,prec);
for(var i=0;i<=this.options.yNumberOfTicks;i++){
var yval=this.minyval+(i*_142);
var pos=1-((yval-this.minyval)*this.yscale);
if((pos>1)||(pos<0)){
continue;
}
this.yticks.push([pos,MochiKit.Format.roundToFixed(yval,prec)]);
}
}
}
};
PlotKit.Layout.prototype._evaluateLineTicks=function(){
this._evaluateLineTicksForXAxis();
this._evaluateLineTicksForYAxis();
};
PlotKit.Layout.prototype._evaluateBarTicks=function(){
this._evaluateLineTicks();
var _144=function(tick){
return [tick[0]+(this.minxdelta*this.xscale)/2,tick[1]];
};
this.xticks=MochiKit.Base.map(MochiKit.Base.bind(_144,this),this.xticks);
if(this.options.barOrientation=="horizontal"){
var _145=this.xticks;
this.xticks=this.yticks;
this.yticks=_145;
var _146=function(tick){
return [1-tick[0],tick[1]];
};
this.xticks=MochiKit.Base.map(_146,this.xticks);
}
};
PlotKit.Layout.prototype._evaluatePieTicks=function(){
var _147=MochiKit.Base.isUndefinedOrNull;
var _148=MochiKit.Format.numberFormatter("#%");
this.xticks=new Array();
if(this.options.xTicks){
var _149=new Array();
for(var i=0;i<this.slices.length;i++){
_149[this.slices[i].xval]=this.slices[i];
}
for(var i=0;i<this.options.xTicks.length;i++){
var tick=this.options.xTicks[i];
var _150=_149[tick.v];
var _151=tick.label;
if(_150){
if(_147(_151)){
_151=tick.v.toString();
}
_151=SPAN(null,_151," ("+_148(_150.fraction)+")");
this.xticks.push([tick.v,_151]);
}
}
}else{
for(var i=0;i<this.slices.length;i++){
var _150=this.slices[i];
var _151=_150.xval+" ("+_148(_150.fraction)+")";
this.xticks.push([_150.xval,_151]);
}
}
};
PlotKit.Layout.prototype._regenerateHitTestCache=function(){
this.hitTestCache.xvalues=this._uniqueXValues();
this.hitTestCache.xlookup=new Array();
this.hitTestCache.x2maxy=new Array();
var _152=MochiKit.Base.listMax;
var _153=MochiKit.Base.itemgetter;
var map=MochiKit.Base.map;
var _154=keys(this.datasets);
for(var i=0;i<_154.length;i++){
var _155=this.datasets[_154[i]];
for(var j=0;j<_155.length;j++){
var xval=_155[j][0];
var yval=_155[j][1];
if(this.hitTestCache.xlookup[xval]){
this.hitTestCache.xlookup[xval].push([yval,_154[i]]);
}else{
this.hitTestCache.xlookup[xval]=[[yval,_154[i]]];
}
}
}
for(var x in this.hitTestCache.xlookup){
var _157=this.hitTestCache.xlookup[x];
this.hitTestCache.x2maxy[x]=_152(map(_153(0),_157));
}
};
PlotKit.LayoutModule={};
PlotKit.LayoutModule.Layout=PlotKit.Layout;
PlotKit.LayoutModule.EXPORT=["Layout"];
PlotKit.LayoutModule.EXPORT_OK=[];
PlotKit.LayoutModule.__new__=function(){
var m=MochiKit.Base;
m.nameFunctions(this);
this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
};
PlotKit.LayoutModule.__new__();
MochiKit.Base._exportSymbols(this,PlotKit.LayoutModule);
try{
if((typeof (PlotKit.Base)=="undefined")||(typeof (PlotKit.Layout)=="undefined")){
throw "";
}
}
catch(e){
throw "PlotKit.Layout depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.{Base,Layout}";
}
if(typeof (PlotKit.CanvasRenderer)=="undefined"){
PlotKit.CanvasRenderer={};
}
PlotKit.CanvasRenderer.NAME="PlotKit.CanvasRenderer";
PlotKit.CanvasRenderer.VERSION=PlotKit.VERSION;
PlotKit.CanvasRenderer.__repr__=function(){
return "["+this.NAME+" "+this.VERSION+"]";
};
PlotKit.CanvasRenderer.toString=function(){
return this.__repr__();
};
PlotKit.CanvasRenderer=function(_158,_159,_160){
if(arguments.length>0){
this.__init__(_158,_159,_160);
}
};
PlotKit.CanvasRenderer.prototype.__init__=function(_161,_162,_163){
var _164=MochiKit.Base.isUndefinedOrNull;
var _165=MochiKit.Color.Color;
this.options={"drawBackground":true,"backgroundColor":_165.whiteColor(),"padding":{left:30,right:30,top:5,bottom:10},"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[0]),"strokeColor":_165.whiteColor(),"strokeColorTransform":"asStrokeColor","strokeWidth":0.5,"fillColorTransform":null,"shouldFill":true,"shouldStroke":true,"drawXAxis":true,"drawYAxis":true,"axisLineColor":_165.blackColor(),"axisLineWidth":0.5,"axisTickSize":3,"axisLabelColor":_165.blackColor(),"axisLabelFont":"Arial","axisLabelFontSize":9,"axisLabelWidth":50,"pieRadius":0.4,"enableEvents":true};
MochiKit.Base.update(this.options,_163?_163:{});
this.layout=_162;
this.element=MochiKit.DOM.getElement(_161);
this.container=this.element.parentNode;
this.isIE=PlotKit.Base.excanvasSupported();
if(this.isIE&&!_164(G_vmlCanvasManager)){
this.IEDelay=0.5;
this.maxTries=5;
this.renderDelay=null;
this.clearDelay=null;
this.element=G_vmlCanvasManager.initElement(this.element);
}
this.height=MochiKit.DOM.elementDimensions(this.element).h;
this.width=MochiKit.DOM.elementDimensions(this.element).w;
this.element.width=this.width;
this.element.height=this.height;
if(_164(this.element)){
throw "CanvasRenderer() - passed canvas is not found";
}
if(!this.isIE&&!(PlotKit.CanvasRenderer.isSupported(this.element))){
throw "CanvasRenderer() - Canvas is not supported.";
}
if(_164(this.container)||(this.container.nodeName.toLowerCase()!="div")){
throw "CanvasRenderer() - <canvas> needs to be enclosed in <div>";
}
this.xlabels=new Array();
this.ylabels=new Array();
this.isFirstRender=true;
this.area={x:this.options.padding.left,y:this.options.padding.top,w:this.width-this.options.padding.left-this.options.padding.right,h:this.height-this.options.padding.top-this.options.padding.bottom};
MochiKit.DOM.updateNodeAttributes(this.container,{"style":{"position":"relative","width":this.width+"px"}});
try{
this.event_isinside=null;
if(MochiKit.Signal&&this.options.enableEvents){
this._initialiseEvents();
}
}
catch(e){
}
};
PlotKit.CanvasRenderer.prototype.render=function(){
if(this.isIE){
try{
if(this.renderDelay){
this.renderDelay.cancel();
this.renderDelay=null;
}
var _166=this.element.getContext("2d");
}
catch(e){
this.isFirstRender=false;
if(this.maxTries-->0){
this.renderDelay=MochiKit.Async.wait(this.IEDelay);
this.renderDelay.addCallback(MochiKit.Base.bind(this.render,this));
}
return;
}
}
if(this.options.drawBackground){
this._renderBackground();
}
if(this.layout.style=="bar"){
this._renderBarChart();
this._renderBarAxis();
}else{
if(this.layout.style=="pie"){
this._renderPieChart();
this._renderPieAxis();
}else{
if(this.layout.style=="line"){
this._renderLineChart();
this._renderLineAxis();
}
}
}
};
PlotKit.CanvasRenderer.prototype._renderBarChartWrap=function(data,_168){
var _169=this.element.getContext("2d");
var _170=this.options.colorScheme.length;
var _171=this.options.colorScheme;
var _172=MochiKit.Base.keys(this.layout.datasets);
var _173=_172.length;
for(var i=0;i<_173;i++){
var _174=_172[i];
var _175=_171[i%_170];
_169.save();
if(this.options.fillColorTransform&&_175[this.options.fillColorTransform]){
_169.fillStyle=_175[this.options.fillColorTransform]().toRGBString();
}else{
_169.fillStyle=_175.toRGBString();
}
if(this.options.strokeColor){
_169.strokeStyle=this.options.strokeColor.toRGBString();
}else{
if(this.options.strokeColorTransform){
_169.strokeStyle=_175[this.options.strokeColorTransform]().toRGBString();
}else{
_169.strokeStyle=_175.toRGBString();
}
}
_169.lineWidth=this.options.strokeWidth;
var _176=function(obj){
if(obj.name==_174){
_168(_169,obj);
}
};
MochiKit.Iter.forEach(data,MochiKit.Base.bind(_176,this));
_169.restore();
}
};
PlotKit.CanvasRenderer.prototype._renderBarChart=function(){
var bind=MochiKit.Base.bind;
var _178=function(_179,bar){
var x=this.area.w*bar.x+this.area.x;
var y=this.area.h*bar.y+this.area.y;
var w=this.area.w*bar.w;
var h=this.area.h*bar.h;
if((w<1)||(h<1)){
return;
}
if(this.options.shouldFill){
_179.fillRect(x,y,w,h);
}
if(this.options.shouldStroke){
_179.strokeRect(x,y,w,h);
}
};
this._renderBarChartWrap(this.layout.bars,bind(_178,this));
};
PlotKit.CanvasRenderer.prototype._renderLineChart=function(){
var _182=this.element.getContext("2d");
var _183=this.options.colorScheme.length;
var _184=this.options.colorScheme;
var _185=MochiKit.Base.keys(this.layout.datasets);
var _186=_185.length;
var bind=MochiKit.Base.bind;
var _187=MochiKit.Base.partial;
for(var i=0;i<_186;i++){
var _188=_185[i];
var _189=_184[i%_183];
var _190=this.options.strokeColorTransform;
_182.save();
if(this.options.fillColorTransform&&_189[this.options.fillColorTransform]){
_182.fillStyle=_189[this.options.fillColorTransform]().toRGBString();
}else{
_182.fillStyle=_189.toRGBString();
}
if(this.options.strokeColor){
_182.strokeStyle=this.options.strokeColor.toRGBString();
}else{
if(this.options.strokeColorTransform){
_182.strokeStyle=_189[this.options.strokeColorTransform]().toRGBString();
}else{
_182.strokeStyle=_189.toRGBString();
}
}
_182.lineWidth=this.options.strokeWidth;
var _191=function(ctx){
ctx.beginPath();
ctx.moveTo(this.area.x,this.area.y+this.area.h);
var _193=function(ctx_,_195){
if(_195.name==_188){
ctx_.lineTo(this.area.w*_195.x+this.area.x,this.area.h*_195.y+this.area.y);
}
};
MochiKit.Iter.forEach(this.layout.points,_187(_193,ctx),this);
if(this.options.shouldFill){
ctx.lineTo(this.area.w+this.area.x,this.area.h+this.area.y);
ctx.lineTo(this.area.x,this.area.y+this.area.h);
ctx.closePath();
}
};
if(this.options.shouldFill){
bind(_191,this)(_182);
_182.fill();
}
if(this.options.shouldStroke){
bind(_191,this)(_182);
_182.stroke();
}
_182.restore();
}
};
PlotKit.CanvasRenderer.prototype._renderPieChart=function(){
var _196=this.element.getContext("2d");
var _197=this.options.colorScheme.length;
var _198=this.layout.slices;
var _199=this.area.x+this.area.w*0.5;
var _200=this.area.y+this.area.h*0.5;
var _201=Math.min(this.area.w*this.options.pieRadius,this.area.h*this.options.pieRadius);
if(this.isIE){
_199=parseInt(_199);
_200=parseInt(_200);
_201=parseInt(_201);
}
for(var i=0;i<_198.length;i++){
var _202=this.options.colorScheme[i%_197];
_196.save();
if(this.options.fillColorTransform&&_202[this.options.fillColorTransform]){
_196.fillStyle=_202[this.options.fillColorTransform]().toRGBString();
}else{
_196.fillStyle=_202.toRGBString();
}
var _203=function(){
_196.beginPath();
_196.moveTo(_199,_200);
_196.arc(_199,_200,_201,_198[i].startAngle-Math.PI/2,_198[i].endAngle-Math.PI/2,false);
_196.lineTo(_199,_200);
_196.closePath();
};
if(Math.abs(_198[i].startAngle-_198[i].endAngle)>0.001){
if(this.options.shouldFill){
_203();
_196.fill();
}
if(this.options.shouldStroke){
_203();
_196.lineWidth=this.options.strokeWidth;
if(this.options.strokeColor){
_196.strokeStyle=this.options.strokeColor.toRGBString();
}else{
if(this.options.strokeColorTransform){
_196.strokeStyle=_202[this.options.strokeColorTransform]().toRGBString();
}else{
_196.strokeStyle=_202.toRGBString();
}
}
_196.stroke();
}
}
_196.restore();
}
};
PlotKit.CanvasRenderer.prototype._renderBarAxis=function(){
this._renderAxis();
};
PlotKit.CanvasRenderer.prototype._renderLineAxis=function(){
this._renderAxis();
};
PlotKit.CanvasRenderer.prototype._renderAxis=function(){
if(!this.options.drawXAxis&&!this.options.drawYAxis){
return;
}
var DIV=MochiKit.DOM.DIV;
var _205=this.element.getContext("2d");
var _206={"style":{"position":"absolute","fontSize":this.options.axisLabelFontSize+"px","zIndex":10,"color":this.options.axisLabelColor.toRGBString(),"width":this.options.axisLabelWidth+"px","overflow":"hidden"}};
_205.save();
_205.strokeStyle=this.options.axisLineColor.toRGBString();
_205.lineWidth=this.options.axisLineWidth;
if(this.options.drawYAxis){
if(this.layout.yticks){
var _207=function(tick){
if(typeof (tick)=="function"){
return;
}
var x=this.area.x;
var y=this.area.y+tick[0]*this.area.h;
_205.beginPath();
_205.moveTo(x,y);
_205.lineTo(x-this.options.axisTickSize,y);
_205.closePath();
_205.stroke();
var _208=DIV(_206,tick[1]);
_208.style.top=(y-this.options.axisLabelFontSize)+"px";
_208.style.left=(x-this.options.padding.left-this.options.axisTickSize)+"px";
_208.style.textAlign="right";
_208.style.width=(this.options.padding.left-this.options.axisTickSize*2)+"px";
MochiKit.DOM.appendChildNodes(this.container,_208);
this.ylabels.push(_208);
};
MochiKit.Iter.forEach(this.layout.yticks,MochiKit.Base.bind(_207,this));
}
_205.beginPath();
_205.moveTo(this.area.x,this.area.y);
_205.lineTo(this.area.x,this.area.y+this.area.h);
_205.closePath();
_205.stroke();
}
if(this.options.drawXAxis){
if(this.layout.xticks){
var _207=function(tick){
if(typeof (dataset)=="function"){
return;
}
var x=this.area.x+tick[0]*this.area.w;
var y=this.area.y+this.area.h;
_205.beginPath();
_205.moveTo(x,y);
_205.lineTo(x,y+this.options.axisTickSize);
_205.closePath();
_205.stroke();
var _209=DIV(_206,tick[1]);
_209.style.top=(y+this.options.axisTickSize)+"px";
_209.style.left=(x-this.options.axisLabelWidth/2)+"px";
_209.style.textAlign="center";
_209.style.width=this.options.axisLabelWidth+"px";
MochiKit.DOM.appendChildNodes(this.container,_209);
this.xlabels.push(_209);
};
MochiKit.Iter.forEach(this.layout.xticks,MochiKit.Base.bind(_207,this));
}
_205.beginPath();
_205.moveTo(this.area.x,this.area.y+this.area.h);
_205.lineTo(this.area.x+this.area.w,this.area.y+this.area.h);
_205.closePath();
_205.stroke();
}
_205.restore();
};
PlotKit.CanvasRenderer.prototype._renderPieAxis=function(){
if(!this.options.drawXAxis){
return;
}
if(this.layout.xticks){
var _210=new Array();
for(var i=0;i<this.layout.slices.length;i++){
_210[this.layout.slices[i].xval]=this.layout.slices[i];
}
var _211=this.area.x+this.area.w*0.5;
var _212=this.area.y+this.area.h*0.5;
var _213=Math.min(this.area.w*this.options.pieRadius,this.area.h*this.options.pieRadius);
var _214=this.options.axisLabelWidth;
for(var i=0;i<this.layout.xticks.length;i++){
var _215=_210[this.layout.xticks[i][0]];
if(MochiKit.Base.isUndefinedOrNull(_215)){
continue;
}
var _216=(_215.startAngle+_215.endAngle)/2;
var _217=_216;
if(_217>Math.PI*2){
_217=_217-Math.PI*2;
}else{
if(_217<0){
_217=_217+Math.PI*2;
}
}
var _218=_211+Math.sin(_217)*(_213+10);
var _219=_212-Math.cos(_217)*(_213+10);
var _220={"position":"absolute","zIndex":11,"width":_214+"px","fontSize":this.options.axisLabelFontSize+"px","overflow":"hidden","color":this.options.axisLabelColor.toHexString()};
if(_217<=Math.PI*0.5){
_220["textAlign"]="left";
_220["verticalAlign"]="top";
_220["left"]=_218+"px";
_220["top"]=(_219-this.options.axisLabelFontSize)+"px";
}else{
if((_217>Math.PI*0.5)&&(_217<=Math.PI)){
_220["textAlign"]="left";
_220["verticalAlign"]="bottom";
_220["left"]=_218+"px";
_220["top"]=_219+"px";
}else{
if((_217>Math.PI)&&(_217<=Math.PI*1.5)){
_220["textAlign"]="right";
_220["verticalAlign"]="bottom";
_220["left"]=(_218-_214)+"px";
_220["top"]=_219+"px";
}else{
_220["textAlign"]="right";
_220["verticalAlign"]="bottom";
_220["left"]=(_218-_214)+"px";
_220["top"]=(_219-this.options.axisLabelFontSize)+"px";
}
}
}
var _221=DIV({"style":_220},this.layout.xticks[i][1]);
this.xlabels.push(_221);
MochiKit.DOM.appendChildNodes(this.container,_221);
}
}
};
PlotKit.CanvasRenderer.prototype._renderBackground=function(){
var _222=this.element.getContext("2d");
_222.save();
_222.fillStyle=this.options.backgroundColor.toRGBString();
_222.fillRect(0,0,this.width,this.height);
_222.restore();
};
PlotKit.CanvasRenderer.prototype.clear=function(){
if(this.isIE){
try{
if(this.clearDelay){
this.clearDelay.cancel();
this.clearDelay=null;
}
var _223=this.element.getContext("2d");
}
catch(e){
this.isFirstRender=false;
this.clearDelay=MochiKit.Async.wait(this.IEDelay);
this.clearDelay.addCallback(MochiKit.Base.bind(this.clear,this));
return;
}
}
var _223=this.element.getContext("2d");
_223.clearRect(0,0,this.width,this.height);
MochiKit.Iter.forEach(this.xlabels,MochiKit.DOM.removeElement);
MochiKit.Iter.forEach(this.ylabels,MochiKit.DOM.removeElement);
this.xlabels=new Array();
this.ylabels=new Array();
};
PlotKit.CanvasRenderer.prototype._initialiseEvents=function(){
var _224=MochiKit.Signal.connect;
var bind=MochiKit.Base.bind;
_224(this.element,"onclick",bind(this.onclick,this));
};
PlotKit.CanvasRenderer.prototype._resolveObject=function(e){
var x=(e.mouse().page.x-PlotKit.Base.findPosX(this.element)-this.area.x)/this.area.w;
var y=(e.mouse().page.y-PlotKit.Base.findPosY(this.element)-this.area.y)/this.area.h;
var _226=this.layout.hitTest(x,y);
if(_226){
return _226;
}
return null;
};
PlotKit.CanvasRenderer.prototype._createEventObject=function(_227,e){
if(_227==null){
return null;
}
e.chart=_227;
return e;
};
PlotKit.CanvasRenderer.prototype.onclick=function(e){
var _228=this._resolveObject(e);
var _229=this._createEventObject(_228,e);
if(_229!=null){
MochiKit.Signal.signal(this,"onclick",_229);
}
};
PlotKit.CanvasRenderer.prototype.onmouseover=function(e){
var _230=this._resolveObject(e);
var _231=this._createEventObject(_230,e);
if(_231!=null){
signal(this,"onmouseover",_231);
}
};
PlotKit.CanvasRenderer.prototype.onmouseout=function(e){
var _232=this._resolveObject(e);
var _233=this._createEventObject(_232,e);
if(_233==null){
signal(this,"onmouseout",e);
}else{
signal(this,"onmouseout",_233);
}
};
PlotKit.CanvasRenderer.prototype.onmousemove=function(e){
var _234=this._resolveObject(e);
var _235=this._createEventObject(_234,e);
if((_234==null)&&(this.event_isinside==null)){
return;
}
if((_234!=null)&&(this.event_isinside==null)){
signal(this,"onmouseover",_235);
}
if((_234==null)&&(this.event_isinside!=null)){
signal(this,"onmouseout",_235);
}
if((_234!=null)&&(this.event_isinside!=null)){
signal(this,"onmousemove",_235);
}
this.event_isinside=_234;
};
PlotKit.CanvasRenderer.isSupported=function(_236){
var _237=null;
try{
if(MochiKit.Base.isUndefinedOrNull(_236)){
_237=MochiKit.DOM.CANVAS({});
}else{
_237=MochiKit.DOM.getElement(_236);
}
var _238=_237.getContext("2d");
}
catch(e){
var ie=navigator.appVersion.match(/MSIE (\d\.\d)/);
var _240=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
if((!ie)||(ie[1]<6)||(_240)){
return false;
}
return true;
}
return true;
};
PlotKit.Canvas={};
PlotKit.Canvas.CanvasRenderer=PlotKit.CanvasRenderer;
PlotKit.Canvas.EXPORT=["CanvasRenderer"];
PlotKit.Canvas.EXPORT_OK=["CanvasRenderer"];
PlotKit.Canvas.__new__=function(){
var m=MochiKit.Base;
m.nameFunctions(this);
this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
};
PlotKit.Canvas.__new__();
MochiKit.Base._exportSymbols(this,PlotKit.Canvas);
try{
if(typeof (PlotKit.Layout)=="undefined"){
throw "";
}
}
catch(e){
throw "PlotKit depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.Layout";
}
PlotKit.SVGRenderer=function(_241,_242,_243){
if(arguments.length>0){
this.__init__(_241,_242,_243);
}
};
PlotKit.SVGRenderer.NAME="PlotKit.SVGRenderer";
PlotKit.SVGRenderer.VERSION=PlotKit.VERSION;
PlotKit.SVGRenderer.__repr__=function(){
return "["+this.NAME+" "+this.VERSION+"]";
};
PlotKit.SVGRenderer.toString=function(){
return this.__repr__();
};
PlotKit.SVGRenderer.SVGNS="http://www.w3.org/2000/svg";
PlotKit.SVGRenderer.prototype.__init__=function(_244,_245,_246){
var _247=MochiKit.Base.isUndefinedOrNull;
this.options={"drawBackground":true,"backgroundColor":Color.whiteColor(),"padding":{left:30,right:30,top:5,bottom:10},"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[1]),"strokeColor":Color.whiteColor(),"strokeColorTransform":"asStrokeColor","strokeWidth":0.5,"shouldFill":true,"shouldStroke":true,"drawXAxis":true,"drawYAxis":true,"axisLineColor":Color.blackColor(),"axisLineWidth":0.5,"axisTickSize":3,"axisLabelColor":Color.blackColor(),"axisLabelFont":"Arial","axisLabelFontSize":9,"axisLabelWidth":50,"axisLabelUseDiv":true,"pieRadius":0.4,"enableEvents":true};
MochiKit.Base.update(this.options,_246?_246:{});
this.layout=_245;
this.element=MochiKit.DOM.getElement(_244);
this.container=this.element.parentNode;
this.height=parseInt(this.element.getAttribute("height"));
this.width=parseInt(this.element.getAttribute("width"));
this.document=document;
this.root=this.element;
try{
this.document=this.element.getSVGDocument();
this.root=_247(this.document.documentElement)?this.element:this.document.documentElement;
}
catch(e){
}
this.element.style.zIndex=1;
if(_247(this.element)){
throw "SVGRenderer() - passed SVG object is not found";
}
if(_247(this.container)||this.container.nodeName.toLowerCase()!="div"){
throw "SVGRenderer() - No DIV's around the SVG.";
}
this.xlabels=new Array();
this.ylabels=new Array();
this.defs=this.createSVGElement("defs");
this.area={x:this.options.padding.left,y:this.options.padding.top,w:this.width-this.options.padding.left-this.options.padding.right,h:this.height-this.options.padding.top-this.options.padding.bottom};
MochiKit.DOM.updateNodeAttributes(this.container,{"style":{"position":"relative","width":this.width+"px"}});
};
PlotKit.SVGRenderer.prototype.render=function(){
if(this.options.drawBackground){
this._renderBackground();
}
if(this.layout.style=="bar"){
this._renderBarChart();
this._renderBarAxis();
}else{
if(this.layout.style=="pie"){
this._renderPieChart();
this._renderPieAxis();
}else{
if(this.layout.style=="line"){
this._renderLineChart();
this._renderLineAxis();
}
}
}
};
PlotKit.SVGRenderer.prototype._renderBarOrLine=function(data,_248,_249,_250){
var _251=this.options.colorScheme.length;
var _252=this.options.colorScheme;
var _253=MochiKit.Base.keys(this.layout.datasets);
var _254=_253.length;
for(var i=0;i<_254;i++){
var _255=_253[i];
var _256=new Array();
var _257=_252[i%_251];
if(this.options.shouldFill){
_256["fill"]=_257.toRGBString();
}else{
_256["fill"]="none";
}
if(this.options.shouldStroke&&(this.options.strokeColor||this.options.strokeColorTransform)){
if(this.options.strokeColor){
_256["stroke"]=this.options.strokeColor.toRGBString();
}else{
if(this.options.strokeColorTransform){
_256["stroke"]=_257[this.options.strokeColorTransform]().toRGBString();
}
}
_256["strokeWidth"]=this.options.strokeWidth;
}
if(_249){
_249(_256);
}
var _258=function(obj){
if(obj.name==_255){
_248(_256,obj);
}
};
MochiKit.Iter.forEach(data,bind(_258,this));
if(_250){
_250(_256);
}
}
};
PlotKit.SVGRenderer.prototype._renderBarChart=function(){
var bind=MochiKit.Base.bind;
var _259=function(_260,bar){
var x=this.area.w*bar.x+this.area.x;
var y=this.area.h*bar.y+this.area.y;
var w=this.area.w*bar.w;
var h=this.area.h*bar.h;
this._drawRect(x,y,w,h,_260);
};
this._renderBarOrLine(this.layout.bars,bind(_259,this));
};
PlotKit.SVGRenderer.prototype._renderLineChart=function(){
var bind=MochiKit.Base.bind;
var _261=function(_262,_263){
this._tempPointsBuffer+=(this.area.w*_263.x+this.area.x)+","+(this.area.h*_263.y+this.area.y)+" ";
};
var _264=function(_265){
this._tempPointsBuffer="";
this._tempPointsBuffer+=(this.area.x)+","+(this.area.y+this.area.h)+" ";
};
var _266=function(_267){
this._tempPointsBuffer+=(this.area.w+this.area.x)+","+(this.area.h+this.area.y);
_267["points"]=this._tempPointsBuffer;
var elem=this.createSVGElement("polygon",_267);
this.root.appendChild(elem);
};
this._renderBarOrLine(this.layout.points,bind(_261,this),bind(_264,this),bind(_266,this));
};
PlotKit.SVGRenderer.prototype._renderPieChart=function(){
var _269=this.options.colorScheme.length;
var _270=this.layout.slices;
var _271=this.area.x+this.area.w*0.5;
var _272=this.area.y+this.area.h*0.5;
var _273=Math.min(this.area.w*this.options.pieRadius,this.area.h*this.options.pieRadius);
if(_270.length==1&&(Math.abs(_270[0].startAngle)-Math.abs(_270[0].endAngle)<0.1)){
var _274={"cx":_271,"cy":_272,"r":_273};
var _275=this.options.colorScheme[0];
if(this.options.shouldFill){
_274["fill"]=_275.toRGBString();
}else{
_274["fill"]="none";
}
if(this.options.shouldStroke&&(this.options.strokeColor||this.options.strokeColorTransform)){
if(this.options.strokeColor){
_274["stroke"]=this.options.strokeColor.toRGBString();
}else{
if(this.options.strokeColorTransform){
_274["stroke"]=_275[this.options.strokeColorTransform]().toRGBString();
}
}
_274["style"]="stroke-width: "+this.options.strokeWidth;
}
this.root.appendChild(this.createSVGElement("circle",_274));
return;
}
for(var i=0;i<_270.length;i++){
var _274=new Array();
var _275=this.options.colorScheme[i%_269];
if(this.options.shouldFill){
_274["fill"]=_275.toRGBString();
}else{
_274["fill"]="none";
}
if(this.options.shouldStroke&&(this.options.strokeColor||this.options.strokeColorTransform)){
if(this.options.strokeColor){
_274["stroke"]=this.options.strokeColor.toRGBString();
}else{
if(this.options.strokeColorTransform){
_274["stroke"]=_275[this.options.strokeColorTransform]().toRGBString();
}
}
_274["style"]="stroke-width:"+this.options.strokeWidth;
}
var _276=0;
if(Math.abs(_270[i].endAngle-_270[i].startAngle)>Math.PI){
_276=1;
}
var x1=Math.cos(_270[i].startAngle-Math.PI/2)*_273;
var y1=Math.sin(_270[i].startAngle-Math.PI/2)*_273;
var x2=Math.cos(_270[i].endAngle-Math.PI/2)*_273;
var y2=Math.sin(_270[i].endAngle-Math.PI/2)*_273;
var rx=x2-x1;
var ry=y2-y1;
var _283="M"+_271+","+_272+" ";
_283+="l"+x1+","+y1+" ";
_283+="a"+_273+","+_273+" 0 "+_276+",1 "+rx+","+ry+" z";
_274["d"]=_283;
var elem=this.createSVGElement("path",_274);
this.root.appendChild(elem);
}
};
PlotKit.SVGRenderer.prototype._renderBarAxis=function(){
this._renderAxis();
};
PlotKit.SVGRenderer.prototype._renderLineAxis=function(){
this._renderAxis();
};
PlotKit.SVGRenderer.prototype._renderAxis=function(){
if(!this.options.drawXAxis&&!this.options.drawYAxis){
return;
}
var _284={"style":{"position":"absolute","textAlign":"center","fontSize":this.options.axisLabelFontSize+"px","zIndex":10,"color":this.options.axisLabelColor.toRGBString(),"width":this.options.axisLabelWidth+"px","overflow":"hidden"}};
var _285={"stroke":this.options.axisLineColor.toRGBString(),"strokeWidth":this.options.axisLineWidth};
if(this.options.drawYAxis){
if(this.layout.yticks){
var _286=function(tick){
var x=this.area.x;
var y=this.area.y+tick[0]*this.area.h;
this._drawLine(x,y,x-3,y,_285);
if(this.options.axisLabelUseDiv){
var _287=DIV(_284,tick[1]);
_287.style.top=(y-this.options.axisLabelFontSize)+"px";
_287.style.left=(x-this.options.padding.left+this.options.axisTickSize)+"px";
_287.style.textAlign="left";
_287.style.width=(this.options.padding.left-3)+"px";
MochiKit.DOM.appendChildNodes(this.container,_287);
this.ylabels.push(_287);
}else{
var _288={y:y+3,x:(x-this.options.padding.left+3),width:(this.options.padding.left-this.options.axisTickSize)+"px",height:(this.options.axisLabelFontSize+3)+"px",fontFamily:"Arial",fontSize:this.options.axisLabelFontSize+"px",fill:this.options.axisLabelColor.toRGBString()};
var _287=this.createSVGElement("text",_288);
_287.appendChild(this.document.createTextNode(tick[1]));
this.root.appendChild(_287);
}
};
MochiKit.Iter.forEach(this.layout.yticks,bind(_286,this));
}
this._drawLine(this.area.x,this.area.y,this.area.x,this.area.y+this.area.h,_285);
}
if(this.options.drawXAxis){
if(this.layout.xticks){
var _286=function(tick){
var x=this.area.x+tick[0]*this.area.w;
var y=this.area.y+this.area.h;
this._drawLine(x,y,x,y+this.options.axisTickSize,_285);
if(this.options.axisLabelUseDiv){
var _289=DIV(_284,tick[1]);
_289.style.top=(y+this.options.axisTickSize)+"px";
_289.style.left=(x-this.options.axisLabelWidth/2)+"px";
_289.style.textAlign="center";
_289.style.width=this.options.axisLabelWidth+"px";
MochiKit.DOM.appendChildNodes(this.container,_289);
this.xlabels.push(_289);
}else{
var _290={y:(y+this.options.axisTickSize+this.options.axisLabelFontSize),x:x-3,width:this.options.axisLabelWidth+"px",height:(this.options.axisLabelFontSize+3)+"px",fontFamily:"Arial",fontSize:this.options.axisLabelFontSize+"px",fill:this.options.axisLabelColor.toRGBString(),textAnchor:"middle"};
var _289=this.createSVGElement("text",_290);
_289.appendChild(this.document.createTextNode(tick[1]));
this.root.appendChild(_289);
}
};
MochiKit.Iter.forEach(this.layout.xticks,bind(_286,this));
}
this._drawLine(this.area.x,this.area.y+this.area.h,this.area.x+this.area.w,this.area.y+this.area.h,_285);
}
};
PlotKit.SVGRenderer.prototype._renderPieAxis=function(){
if(this.layout.xticks){
var _291=new Array();
for(var i=0;i<this.layout.slices.length;i++){
_291[this.layout.slices[i].xval]=this.layout.slices[i];
}
var _292=this.area.x+this.area.w*0.5;
var _293=this.area.y+this.area.h*0.5;
var _294=Math.min(this.area.w*this.options.pieRadius+10,this.area.h*this.options.pieRadius+10);
var _295=this.options.axisLabelWidth;
for(var i=0;i<this.layout.xticks.length;i++){
var _296=_291[this.layout.xticks[i][0]];
if(MochiKit.Base.isUndefinedOrNull(_296)){
continue;
}
var _297=(_296.startAngle+_296.endAngle)/2;
var _298=_297;
if(_298>Math.PI*2){
_298=_298-Math.PI*2;
}else{
if(_298<0){
_298=_298+Math.PI*2;
}
}
var _299=_292+Math.sin(_298)*(_294+10);
var _300=_293-Math.cos(_298)*(_294+10);
var _301={"position":"absolute","zIndex":11,"width":_295+"px","fontSize":this.options.axisLabelFontSize+"px","overflow":"hidden","color":this.options.axisLabelColor.toHexString()};
var _302={"width":_295+"px","fontSize":this.options.axisLabelFontSize+"px","height":(this.options.axisLabelFontSize+3)+"px","fill":this.options.axisLabelColor.toRGBString()};
if(_298<=Math.PI*0.5){
MochiKit.Base.update(_301,{"textAlign":"left","verticalAlign":"top","left":_299+"px","top":(_300-this.options.axisLabelFontSize)+"px"});
MochiKit.Base.update(_302,{"x":_299,"y":(_300-this.options.axisLabelFontSize),"textAnchor":"left"});
}else{
if((_298>Math.PI*0.5)&&(_298<=Math.PI)){
MochiKit.Base.update(_301,{"textAlign":"left","verticalAlign":"bottom","left":_299+"px","top":_300+"px"});
MochiKit.Base.update(_302,{"textAnchor":"left","x":_299,"y":_300});
}else{
if((_298>Math.PI)&&(_298<=Math.PI*1.5)){
MochiKit.Base.update(_301,{"textAlign":"right","verticalAlign":"bottom","left":_299+"px","top":_300+"px"});
MochiKit.Base.update(_302,{"textAnchor":"right","x":_299-_295,"y":_300});
}else{
MochiKit.Base.update(_301,{"textAlign":"left","verticalAlign":"bottom","left":_299+"px","top":_300+"px"});
MochiKit.Base.update(_302,{"textAnchor":"left","x":_299-_295,"y":_300-this.options.axisLabelFontSize});
}
}
}
if(this.options.axisLabelUseDiv){
var _303=DIV({"style":_301},this.layout.xticks[i][1]);
this.xlabels.push(_303);
MochiKit.DOM.appendChildNodes(this.container,_303);
}else{
var _303=this.createSVGElement("text",_302);
_303.appendChild(this.document.createTextNode(this.layout.xticks[i][1]));
this.root.appendChild(_303);
}
}
}
};
PlotKit.SVGRenderer.prototype._renderBackground=function(){
var opts={"stroke":"none","fill":this.options.backgroundColor.toRGBString()};
this._drawRect(0,0,this.width,this.height,opts);
};
PlotKit.SVGRenderer.prototype._drawRect=function(x,y,w,h,_305){
var _306={x:x+"px",y:y+"px",width:w+"px",height:h+"px"};
if(_305){
MochiKit.Base.update(_306,_305);
}
var elem=this.createSVGElement("rect",_306);
this.root.appendChild(elem);
};
PlotKit.SVGRenderer.prototype._drawLine=function(x1,y1,x2,y2,_307){
var _308={x1:x1+"px",y1:y1+"px",x2:x2+"px",y2:y2+"px"};
if(_307){
MochiKit.Base.update(_308,_307);
}
var elem=this.createSVGElement("line",_308);
this.root.appendChild(elem);
};
PlotKit.SVGRenderer.prototype.clear=function(){
while(this.element.firstChild){
this.element.removeChild(this.element.firstChild);
}
if(this.options.axisLabelUseDiv){
for(var i=0;i<this.xlabels.length;i++){
MochiKit.DOM.removeElement(this.xlabels[i]);
}
for(var i=0;i<this.ylabels.length;i++){
MochiKit.DOM.removeElement(this.ylabels[i]);
}
}
this.xlabels=new Array();
this.ylabels=new Array();
};
PlotKit.SVGRenderer.prototype.createSVGElement=function(name,_310){
var _311=MochiKit.Base.isUndefinedOrNull;
var elem;
var doc=_311(this.document)?document:this.document;
try{
elem=doc.createElementNS(PlotKit.SVGRenderer.SVGNS,name);
}
catch(e){
elem=doc.createElement(name);
elem.setAttribute("xmlns",PlotKit.SVGRenderer.SVGNS);
}
if(_310){
MochiKit.DOM.updateNodeAttributes(elem,_310);
}
return elem;
};
PlotKit.SVGRenderer.SVG=function(_313){
var ie=navigator.appVersion.match(/MSIE (\d\.\d)/);
var _314=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
if(ie&&(ie[1]>=6)&&(!_314)){
var _315=_313["width"]?_313["width"]:"100";
var _316=_313["height"]?_313["height"]:"100";
var eid=_313["id"]?_313["id"]:"notunique";
var html="<svg:svg width=\""+_315+"\" height=\""+_316+"\" ";
html+="id=\""+eid+"\" version=\"1.1\" baseProfile=\"full\" />";
var _319=document.createElement(html);
var _320=_319.getSVGDocument().createElementNS(PlotKit.SVGRenderer.SVGNS,"svg");
_320.setAttribute("width",_315);
_320.setAttribute("height",_316);
_319.getSVGDocument().appendChild(_320);
return _319;
}else{
return PlotKit.SVGRenderer.prototype.createSVGElement("svg",_313);
}
};
PlotKit.SVGRenderer.isSupported=function(){
var _321=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
var _322=navigator.appVersion.match(/MSIE (\d\.\d)/);
var _323=navigator.userAgent.match(/AppleWebKit\/(\d+)/);
var _324=navigator.userAgent.match(/Opera\/(\d*\.\d*)/);
var _325=navigator.userAgent.match(/rv:(\d*\.\d*).*Gecko/);
var _326="http://www.w3.org/TR/SVG11/feature#SVG";
if(_322&&(_322[1]>=6)&&!_321){
return document.implementation.hasFeature(_326,"1.1");
}
if(_324&&(_324[1]>8.9)){
return true;
}
if(_325&&(_325>1.7)){
return true;
}
return false;
};
PlotKit.SVG={};
PlotKit.SVG.SVGRenderer=PlotKit.SVGRenderer;
PlotKit.SVG.EXPORT=["SVGRenderer"];
PlotKit.SVG.EXPORT_OK=["SVGRenderer"];
PlotKit.SVG.__new__=function(){
var m=MochiKit.Base;
m.nameFunctions(this);
this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
};
PlotKit.SVG.__new__();
MochiKit.Base._exportSymbols(this,PlotKit.SVG);
try{
if(typeof (PlotKit.CanvasRenderer)=="undefined"){
throw "";
}
}
catch(e){
throw "SweetCanvas depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.{Layout, Canvas}";
}
if(typeof (PlotKit.SweetCanvasRenderer)=="undefined"){
PlotKit.SweetCanvasRenderer={};
}
PlotKit.SweetCanvasRenderer=function(_327,_328,_329){
if(arguments.length>0){
this.__init__(_327,_328,_329);
}
};
PlotKit.SweetCanvasRenderer.NAME="PlotKit.SweetCanvasRenderer";
PlotKit.SweetCanvasRenderer.VERSION=PlotKit.VERSION;
PlotKit.SweetCanvasRenderer.__repr__=function(){
return "["+this.NAME+" "+this.VERSION+"]";
};
PlotKit.SweetCanvasRenderer.toString=function(){
return this.__repr__();
};
PlotKit.SweetCanvasRenderer.prototype=new PlotKit.CanvasRenderer();
PlotKit.SweetCanvasRenderer.prototype.constructor=PlotKit.SweetCanvasRenderer;
PlotKit.SweetCanvasRenderer.__super__=PlotKit.CanvasRenderer.prototype;
PlotKit.SweetCanvasRenderer.prototype.__init__=function(el,_331,opts){
var _332=PlotKit.Base.officeBlue();
MochiKit.Base.update(_332,opts);
PlotKit.SweetCanvasRenderer.__super__.__init__.call(this,el,_331,_332);
};
PlotKit.SweetCanvasRenderer.prototype._renderBarChart=function(){
var bind=MochiKit.Base.bind;
var _333=MochiKit.Color.Color.blackColor().colorWithAlpha(0.1).toRGBString();
var _334=function(_335,x,y,w,h){
_335.fillStyle=_333;
_335.fillRect(x-2,y-2,w+4,h+2);
_335.fillStyle=_333;
_335.fillRect(x-1,y-1,w+2,h+1);
};
var _336=this.options.colorScheme.length;
var _337=this.options.colorScheme;
var _338=PlotKit.Base.keys(this.layout.datasets);
var _339=_338.length;
var _340=function(name){
for(var i=0;i<_339;i++){
if(name==_338[i]){
return _337[i%_336];
}
}
return _337[0];
};
var _341=function(_342,bar){
var x=this.area.w*bar.x+this.area.x;
var y=this.area.h*bar.y+this.area.y;
var w=this.area.w*bar.w;
var h=this.area.h*bar.h;
if((w<1)||(h<1)){
return;
}
_342.save();
_342.shadowBlur=5;
_342.shadowColor=MochiKit.Color.Color.fromHexString("#888888").toRGBString();
if(this.isIE){
_342.save();
_342.fillStyle="#cccccc";
_342.fillRect(x-2,y-2,w+4,h+2);
_342.restore();
}else{
_334(_342,x,y,w,h);
}
if(this.options.shouldFill){
_342.fillStyle=_340(bar.name).toRGBString();
_342.fillRect(x,y,w,h);
}
_342.shadowBlur=0;
_342.strokeStyle=MochiKit.Color.Color.whiteColor().toRGBString();
_342.lineWidth=2;
if(this.options.shouldStroke){
_342.strokeRect(x,y,w,h);
}
_342.restore();
};
this._renderBarChartWrap(this.layout.bars,bind(_341,this));
};
PlotKit.SweetCanvasRenderer.prototype._renderLineChart=function(){
var _343=this.element.getContext("2d");
var _344=this.options.colorScheme.length;
var _345=this.options.colorScheme;
var _346=PlotKit.Base.keys(this.layout.datasets);
var _347=_346.length;
var bind=MochiKit.Base.bind;
for(var i=0;i<_347;i++){
var _348=_346[i];
var _349=_345[i%_344];
var _350=this.options.strokeColorTransform;
_343.save();
var _351=function(ctx){
ctx.beginPath();
ctx.moveTo(this.area.x,this.area.y+this.area.h);
var _352=function(ctx_,_353){
if(_353.name==_348){
ctx_.lineTo(this.area.w*_353.x+this.area.x,this.area.h*_353.y+this.area.y);
}
};
MochiKit.Iter.forEach(this.layout.points,partial(_352,ctx),this);
ctx.lineTo(this.area.w+this.area.x,this.area.h+this.area.y);
ctx.lineTo(this.area.x,this.area.y+this.area.h);
ctx.closePath();
};
if(this.options.shouldFill){
_343.save();
if(this.isIE){
_343.fillStyle="#cccccc";
}else{
_343.fillStyle=MochiKit.Color.Color.blackColor().colorWithAlpha(0.2).toRGBString();
}
_343.translate(-1,-2);
bind(_351,this)(_343);
if(this.options.shouldFill){
_343.fill();
}
_343.restore();
}
_343.shadowBlur=5;
_343.shadowColor=MochiKit.Color.Color.fromHexString("#888888").toRGBString();
_343.fillStyle=_349.toRGBString();
_343.lineWidth=2;
_343.strokeStyle=MochiKit.Color.Color.whiteColor().toRGBString();
if(this.options.shouldFill){
bind(_351,this)(_343);
_343.fill();
}
if(this.options.shouldStroke){
bind(_351,this)(_343);
_343.stroke();
}
_343.restore();
}
};
PlotKit.SweetCanvasRenderer.prototype._renderPieChart=function(){
var _354=this.element.getContext("2d");
var _355=this.options.colorScheme.length;
var _356=this.layout.slices;
var _357=this.area.x+this.area.w*0.5;
var _358=this.area.y+this.area.h*0.5;
var _359=Math.min(this.area.w*this.options.pieRadius,this.area.h*this.options.pieRadius);
if(this.isIE){
_357=parseInt(_357);
_358=parseInt(_358);
_359=parseInt(_359);
}
if(!this.isIE){
_354.save();
var _360=MochiKit.Color.Color.blackColor().colorWithAlpha(0.2);
_354.fillStyle=_360.toRGBString();
_354.shadowBlur=5;
_354.shadowColor=MochiKit.Color.Color.fromHexString("#888888").toRGBString();
_354.translate(1,1);
_354.beginPath();
_354.moveTo(_357,_358);
_354.arc(_357,_358,_359+2,0,Math.PI*2,false);
_354.closePath();
_354.fill();
_354.restore();
}
_354.save();
_354.strokeStyle=MochiKit.Color.Color.whiteColor().toRGBString();
_354.lineWidth=2;
for(var i=0;i<_356.length;i++){
var _361=this.options.colorScheme[i%_355];
_354.fillStyle=_361.toRGBString();
var _362=function(){
_354.beginPath();
_354.moveTo(_357,_358);
_354.arc(_357,_358,_359,_356[i].startAngle-Math.PI/2,_356[i].endAngle-Math.PI/2,_356[i].fraction==1);
_354.lineTo(_357,_358);
_354.closePath();
};
if(Math.abs(_356[i].startAngle-_356[i].endAngle)>0.0001){
if(this.options.shouldFill){
_362();
_354.fill();
}
if(this.options.shouldStroke){
_362();
_354.stroke();
}
}
}
_354.restore();
};
PlotKit.SweetCanvasRenderer.prototype._renderBackground=function(){
var _363=this.element.getContext("2d");
if(this.layout.style=="bar"||this.layout.style=="line"){
_363.save();
_363.fillStyle=this.options.backgroundColor.toRGBString();
_363.fillRect(this.area.x,this.area.y,this.area.w,this.area.h);
_363.strokeStyle=this.options.axisLineColor.toRGBString();
_363.lineWidth=1;
var _364=this.layout.yticks;
var _365=false;
if(this.layout.style=="bar"&&this.layout.options.barOrientation=="horizontal"){
_364=this.layout.xticks;
_365=true;
}
for(var i=0;i<_364.length;i++){
var x1=0;
var y1=0;
var x2=0;
var y2=0;
if(_365){
x1=_364[i][0]*this.area.w+this.area.x;
y1=this.area.y;
x2=x1;
y2=y1+this.area.h;
}else{
x1=this.area.x;
y1=_364[i][0]*this.area.h+this.area.y;
x2=x1+this.area.w;
y2=y1;
}
_363.beginPath();
_363.moveTo(x1,y1);
_363.lineTo(x2,y2);
_363.closePath();
_363.stroke();
}
_363.restore();
}else{
PlotKit.SweetCanvasRenderer.__super__._renderBackground.call(this);
}
};
PlotKit.SweetCanvas={};
PlotKit.SweetCanvas.SweetCanvasRenderer=PlotKit.SweetCanvasRenderer;
PlotKit.SweetCanvas.EXPORT=["SweetCanvasRenderer"];
PlotKit.SweetCanvas.EXPORT_OK=["SweetCanvasRenderer"];
PlotKit.SweetCanvas.__new__=function(){
var m=MochiKit.Base;
m.nameFunctions(this);
this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
};
PlotKit.SweetCanvas.__new__();
MochiKit.Base._exportSymbols(this,PlotKit.SweetCanvas);
try{
if(typeof (PlotKit.SVGRenderer)=="undefined"){
throw "";
}
}
catch(e){
throw "SweetSVG depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.{Layout, SVG}";
}
if(typeof (PlotKit.SweetSVGRenderer)=="undefined"){
PlotKit.SweetSVGRenderer={};
}
PlotKit.SweetSVGRenderer=function(_366,_367,_368){
if(arguments.length>0){
this.__init__(_366,_367,_368);
}
};
PlotKit.SweetSVGRenderer.NAME="PlotKit.SweetSVGRenderer";
PlotKit.SweetSVGRenderer.VERSION=PlotKit.VERSION;
PlotKit.SweetSVGRenderer.__repr__=function(){
return "["+this.NAME+" "+this.VERSION+"]";
};
PlotKit.SweetSVGRenderer.toString=function(){
return this.__repr__();
};
PlotKit.SweetSVGRenderer.prototype=new PlotKit.SVGRenderer();
PlotKit.SweetSVGRenderer.prototype.constructor=PlotKit.SweetSVGRenderer;
PlotKit.SweetSVGRenderer.__super__=PlotKit.SVGRenderer.prototype;
PlotKit.SweetSVGRenderer.prototype.__init__=function(_369,_370,_371){
var _372=PlotKit.Base.officeBlue();
MochiKit.Base.update(_372,_371);
PlotKit.SweetSVGRenderer.__super__.__init__.call(this,_369,_370,_372);
};
PlotKit.SweetSVGRenderer.prototype._addDropShadowFilter=function(){
var _373=this.createSVGElement("filter",{x:0,y:0,"id":"dropShadow"});
var _374=this.createSVGElement("feOffset",{"in":"SourceGraphic","dx":0,"dy":0,"result":"topCopy"});
var blur=this.createSVGElement("feGaussianBlur",{"in":"SourceAlpha","StdDeviation":2,"result":"shadow"});
var _376=this.createSVGElement("feOffset",{"in":"shadow","dx":-1,"dy":-2,"result":"movedShadow"});
var _377=this.createSVGElement("feMerge");
var _378=this.createSVGElement("feMergeNode",{"in":"topCopy"});
var _379=this.createSVGElement("feMergeNode",{"in":"movedShadow"});
_377.appendChild(_378);
_377.appendChild(_379);
_373.appendChild(_374);
_373.appendChild(blur);
_373.appendChild(_376);
_373.appendChild(_377);
this.defs.appendChild(_373);
};
PlotKit.SweetSVGRenderer.prototype._renderBarChart=function(){
var bind=MochiKit.Base.bind;
var _380=Color.blackColor().toRGBString();
var _381="fill:"+_380+";fill-opacity:0.15";
var _382="stroke-width: 2.0; stroke:"+Color.whiteColor().toRGBString();
var _383=function(_384,bar){
var x=this.area.w*bar.x+this.area.x;
var y=this.area.h*bar.y+this.area.y;
var w=this.area.w*bar.w;
var h=this.area.h*bar.h;
if((w<1)||(h<1)){
return;
}
_384["style"]=_382;
this._drawRect(x-2,y-1,w+4,h+2,{"style":_381});
this._drawRect(x,y,w,h,_384);
};
this._renderBarOrLine(this.layout.bars,bind(_383,this));
};
PlotKit.SweetSVGRenderer.prototype._renderLineChart=function(){
var bind=MochiKit.Base.bind;
var _385=Color.blackColor().toRGBString();
var _386="fill:"+_385+";fill-opacity:0.15";
var _387="stroke-width: 2.0; stroke:"+Color.whiteColor().toRGBString();
var _388=function(_389,_390){
this._tempPointsBuffer+=(this.area.w*_390.x+this.area.x)+","+(this.area.h*_390.y+this.area.y)+" ";
};
var _391=function(_392){
this._tempPointsBuffer="";
this._tempPointsBuffer+=(this.area.x)+","+(this.area.y+this.area.h)+" ";
};
var _393=function(_394){
this._tempPointsBuffer+=(this.area.w+this.area.x)+","+(this.area.h+this.area.y);
_394["points"]=this._tempPointsBuffer;
_394["stroke"]="none";
_394["transform"]="translate(-2, -1)";
_394["style"]=_386;
var _395=this.createSVGElement("polygon",_394);
this.root.appendChild(_395);
_394["transform"]="";
_394["style"]=_387;
var elem=this.createSVGElement("polygon",_394);
this.root.appendChild(elem);
};
this._renderBarOrLine(this.layout.points,bind(_388,this),bind(_391,this),bind(_393,this));
};
PlotKit.SweetSVGRenderer.prototype._renderPieChart=function(){
var _396=this.area.x+this.area.w*0.5;
var _397=this.area.y+this.area.h*0.5;
var _398=Color.blackColor().toRGBString();
var _399=Math.min(this.area.w*this.options.pieRadius,this.area.h*this.options.pieRadius);
var _400="fill:"+_398+";fill-opacity:0.15";
var _401=this.createSVGElement("circle",{"style":_400,"cx":_396+1,"cy":_397+1,"r":_399+1});
this.root.appendChild(_401);
PlotKit.SweetSVGRenderer.__super__._renderPieChart.call(this);
};
PlotKit.SweetSVGRenderer.prototype._renderBackground=function(){
var _402={"fill":this.options.backgroundColor.toRGBString(),"stroke":"none"};
if(this.layout.style=="bar"||this.layout.style=="line"){
this._drawRect(this.area.x,this.area.y,this.area.w,this.area.h,_402);
var _403=this.layout.yticks;
var _404=false;
if(this.layout.style=="bar"&&this.layout.options.barOrientation=="horizontal"){
_403=this.layout.xticks;
_404=true;
}
for(var i=0;i<_403.length;i++){
var x=0;
var y=0;
var w=0;
var h=0;
if(_404){
x=_403[i][0]*this.area.w+this.area.x;
y=this.area.y;
w=1;
h=this.area.w;
}else{
x=this.area.x;
y=_403[i][0]*this.area.h+this.area.y;
w=this.area.w;
h=1;
}
this._drawRect(x,y,w,h,{"fill":this.options.axisLineColor.toRGBString()});
}
}else{
PlotKit.SweetSVGRenderer.__super__._renderBackground.call(this);
}
};
PlotKit.SweetSVG={};
PlotKit.SweetSVG.SweetSVGRenderer=PlotKit.SweetSVGRenderer;
PlotKit.SweetSVG.EXPORT=["SweetSVGRenderer"];
PlotKit.SweetSVG.EXPORT_OK=["SweetSVGRenderer"];
PlotKit.SweetSVG.__new__=function(){
var m=MochiKit.Base;
m.nameFunctions(this);
this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
};
PlotKit.SweetSVG.__new__();
MochiKit.Base._exportSymbols(this,PlotKit.SweetSVG);
try{
if(typeof (PlotKit.CanvasRenderer)=="undefined"){
throw "";
}
}
catch(e){
throw "PlotKit.EasyPlot depends on all of PlotKit's components";
}
if(typeof (PlotKit.EasyPlot)=="undefined"){
PlotKit.EasyPlot={};
}
PlotKit.EasyPlot.NAME="PlotKit.EasyPlot";
PlotKit.EasyPlot.VERSION=PlotKit.VERSION;
PlotKit.EasyPlot.__repr__=function(){
return "["+this.NAME+" "+this.VERSION+"]";
};
PlotKit.EasyPlot.toString=function(){
return this.__repr__();
};
PlotKit.EasyPlot=function(_405,_406,_407,_408){
this.layout=new Layout(_405,_406);
this.divElem=_407;
this.width=parseInt(_407.getAttribute("width"));
this.height=parseInt(_407.getAttribute("height"));
this.deferredCount=0;
if(this.width<1){
this.width=this.divElem.width?this.divElem.width:300;
}
if(this.height<1){
this.height=this.divElem.height?this.divElem.height:300;
}
if(isArrayLike(_408)){
for(var i=0;i<_408.length;i++){
if(typeof (_408[i])=="string"){
this.deferredCount++;
var d=MochiKit.Async.doSimpleXMLHttpRequest(_408[i]);
d.addCallback(MochiKit.Base.bind(PlotKit.EasyPlot.onDataLoaded,this));
}else{
if(isArrayLike(_408[i])){
this.layout.addDataset("data-"+i,_408[i]);
}
}
}
}else{
if(!isUndefinedOrNull(_408)){
throw "Passed datasources are not Array like";
}
}
if(CanvasRenderer.isSupported()){
this.element=CANVAS({"id":this.divElem.getAttribute("id")+"-canvas","width":this.width,"height":this.height},"");
this.divElem.appendChild(this.element);
this.renderer=new SweetCanvasRenderer(this.element,this.layout,_406);
}else{
if(SVGRenderer.isSupported()){
this.element=SVGRenderer.SVG({"id":this.divElem.getAttribute("id")+"-svg","width":this.width,"height":this.height,"version":"1.1","baseProfile":"full"},"");
this.divElem.appendChild(this.element);
this.renderer=new SweetSVGRenderer(this.element,this.layout,_406);
}
}
if((this.deferredCount==0)&&(PlotKit.Base.keys(this.layout.datasets).length>0)){
this.layout.evaluate();
this.renderer.clear();
this.renderer.render();
}
};
PlotKit.EasyPlot.onDataLoaded=function(_410){
var _411=new Array();
var _412=_410.responseText.split("\n");
for(var i=0;i<_412.length;i++){
var _413=MochiKit.Format.strip(_412[i]);
if((_413.length>1)&&(_413.charAt(0)!="#")){
_411.push(_413.split(","));
}
}
this.layout.addDataset("data-ajax-"+this.deferredCount,_411);
this.deferredCount--;
if((this.deferredCount==0)&&(PlotKit.Base.keys(this.layout.datasets).length>0)){
this.layout.evaluate();
this.renderer.clear();
this.renderer.render();
}
};
PlotKit.EasyPlot.prototype.reload=function(){
this.layout.evaluate();
this.renderer.clear();
this.renderer.render();
};
PlotKit.EasyPlotModule={};
PlotKit.EasyPlotModule.EasyPlot=PlotKit.EasyPlot;
PlotKit.EasyPlotModule.EXPORT=["EasyPlot"];
PlotKit.EasyPlotModule.EXPORT_OK=[];
PlotKit.EasyPlotModule.__new__=function(){
var m=MochiKit.Base;
m.nameFunctions(this);
this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
};
PlotKit.EasyPlotModule.__new__();
MochiKit.Base._exportSymbols(this,PlotKit.EasyPlotModule);


